<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        body{
            width: 100vw;
            height: 100vh;
            font-size: 3em;
            padding: 30px;
            transition: 2s;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #34495e;
            color: #34495e;
        }
    </style>
</head>
<body>
    houdurnen.com
</body>
</html>
<script>
    //随机颜色切换
    //对象的属性   应该全部使用属性
    function Color(elem){
        this.elem = elem;
        this.color =  ["#74b9ff", "#ffeaa7", "#fab1a0", "#fd79a8"];
        //匿名函数都是window对象   window对象查找不到当前对象里面的方法
        this.run = function(){
                setInterval(function(){
                //生成随机数
                let i =Math.floor(Math.random() * this.color.length);
                this.elem.style.background = this.color[i];
            }.bind(this),1000);
        }
         
    }
    // let body = document.querySelector('body');
   let obj =  new Color(document.body);
   obj.run();
</script>